/*
 * This file is part of dht11 proteus model.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * Copyright 2013 Antonio Diaz. University of Granada. Spain
 */
#pragma once

using namespace System;

#define S_PS 1000000000000
#define MS_PS (1000000000)
#define US_PS (1000000)

class DHT11 : public IACTIVEMODEL, public IDSIMMODEL 
{
public:
	DHT11();
	~DHT11();
	VOID initialize (ICOMPONENT *cpt);
	ISPICEMODEL *getspicemodel (CHAR *device);
	IDSIMMODEL *getdsimmodel (CHAR *device);
	VOID plot (ACTIVESTATE state);
	VOID animate (INT element, ACTIVEDATA *newstate);
	BOOL actuate (WORD key, INT x, INT y, DWORD flags);
	virtual INT isdigital (CHAR *pinname);
	virtual VOID runctrl (RUNMODES mode);
	virtual VOID actuate (REALTIME time, ACTIVESTATE newstate);
	virtual BOOL indicate (REALTIME time, ACTIVEDATA *newstate);
	VOID setup (IINSTANCE *, IDSIMCKT *dsim);
	VOID simulate (ABSTIME time, DSIMMODES mode);
	VOID callback (ABSTIME time, EVENTID eventid);
	ISIBLING *queryinterface (UINT iid);

private:
	VOID update_display(VOID);
	IINSTANCE *instance;
	POINT xypos;
	IDSIMCKT *dsim;                                  
	IDSIMPIN *data;                                                      
	CHAR device[32];
	CHAR dprimitive[32];
	ICOMPONENT *component;
	float humidity, temperature;
	CHAR dht_data[5];
	int state;
	bool mode;
	ABSTIME t0;
	float maxh, maxt, minh,mint,steph,stept;
};


